#include <cstdio>

using namespace std;

const int maxn=1000000;

class Ele {
    public:
        int v, id;
};

Ele operator-(Ele a, Ele b) {return Ele{a.v-b.v, a.id};}

bool operator<(Ele a, Ele b) {return a.v<b.v || (a.v==b.v && a.id<b.id);}

Ele getMax(Ele a[], int &ah, int &at, Ele b[], int &bh, int &bt) {
    if ((ah<=at && b[bh]<a[at]) || bh>bt) return a[at];
    else return b[bh];
}

void popMax(Ele a[], int &ah, int &at, Ele b[], int &bh, int &bt) {
    if ((ah<=at && b[bh]<a[at]) || bh>bt) at--;
    else bh++;
}

Ele getMin(Ele a[], int &ah, int &at, Ele b[], int &bh, int &bt) {
    if ((ah<=at && a[ah]<b[bt]) || bh>bt) return a[ah];
    else return b[bt];
}

void popMin(Ele a[], int &ah, int &at, Ele b[], int &bh, int &bt) {
    if ((ah<=at && a[ah]<b[bt]) || bh>bt) ah++;
    else bt--;
}

int check(Ele a[], int ah, int at, Ele b[], int bh, int bt) {
    int ret=0;
    for (; at-ah+1+bt-bh+1>2; ret=!ret) {
        Ele u=getMax(a, ah, at, b, bh, bt), v=getMin(a, ah, at, b, bh, bt), w;
        popMin(a, ah, at, b, bh, bt);
        w=getMin(a, ah, at, b, bh, bt);
        popMax(a, ah, at, b, bh, bt);
        b[++bt] = u-v;
        if (w<u-v) return ret;
    }
    return ret;
}

int solve(int n, Ele a[]) {
    static Ele b[maxn+1];
    int ah=1, at=n, bh=1, bt=0, ans=0;
    for (;at-ah+1+bt-bh+1>2;) {
        Ele u=getMax(a, ah, at, b, bh, bt), v=getMin(a, ah, at, b, bh, bt), w;
        popMin(a, ah, at, b, bh, bt);
        w=getMin(a, ah, at, b, bh, bt);
        popMax(a, ah, at, b, bh, bt);
        b[++bt] = u-v;
        if (u-v<w) {
            return at+bt-ah-bh+3-check(a, ah, at, b, bh, bt);
        }
    }
    return at+bt-ah-bh+2>2 ? at+bt-ah-bh+2 : 1;
}

int main() {
    freopen("snakes.in", "r", stdin);
    freopen("snakes.out", "w", stdout);

    static Ele a[maxn+1];
    int t, n;
    scanf("%d %d", &t, &n);
    for (int i=1; i<=n; i++) {
        scanf("%d", &a[i].v);
        a[i].id = i;
    }
    printf("%d\n", solve(n, a));
    for (t--; t; t--) {
        int k;
        scanf("%d", &k);
        for (int i=1; i<=k; i++) {
            int u, v;
            scanf("%d %d", &u, &v);
            a[u].v = v;
        }
        printf("%d\n", solve(n, a));
    }

    fclose(stdin);
    fclose(stdout);
    return 0;
}
